package cn.txun.csmall.product.preload;

import cn.txun.csmall.product.cache.IBrandRepository;
import cn.txun.csmall.product.mapper.BrandMapper;
import cn.txun.csmall.product.pojo.vo.BrandStandardVO;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;

import java.io.Serializable;

@Slf4j
@Component
public class CachePreload implements ApplicationRunner {
    @Autowired
    private BrandMapper brandMapper;
    @Autowired
    private IBrandRepository brandRepository;

    @Override
    public void run(ApplicationArguments args) throws Exception {
        //这里就可以写同步数据库数据到redis缓存中

      /*  int rows = brandMapper.selectCount(null);
        for(int id=1 ; id<=rows ;id++){
            BrandStandardVO standard = brandMapper.getStandardById(id+0L);
            if(standard != null){
                brandRepository.save(standard);
            }
        }
        System.out.println("向redis中插入全部的品牌数据");*/
       log.debug("CachePreload.run");
    }
}
